﻿app.controller('OrderDishesCtrl', ['$scope', '$http', '$state', '$stateParams', 'httpPlus', 'testData','maskPlus', function ($scope, $http, $state, $stateParams, httpPlus, testData,maskPlus) {
    $scope.height = document.body.clientHeight - 50;
    $scope.height1 = document.body.clientHeight - 46;
    $scope.standardsDetails = false;
    $scope.mealDetials = false;
    $scope.currMenuItem = undefined;
    var billid = $stateParams.billid;
    var code = $stateParams.code;
    //member
    $scope.memberDetail = {};

    //CurrMnuItem 普通菜品
    function NormalMenuItem(_par) {
        var self = this;
        self.name = _par.name;
        self.code = _par.code;
        self.remark = _par.remark;
        self.typecode = _par.typecode;
        self.picpath = _par.picpath;
        self.standards = _par.standards;
        self.currStandard = self.standards[0];
        self.recipes = _par.recipes;
        self.currRecipes = [];
        self.hasCountMeal = function () {
            return _.some(self.standards,function(val){return val.count > 0})
        };
        self.isOneStandards = function () {
            return self.standards.length == 1 && self.recipes.length == 0;
        };

        self.btnMinusCount_click = function () {
            if (self.currStandard.count > 0) {
                self.currStandard.count -= 1;
            }
        };
        self.btnAddCount_click = function () {
            if( self.currStandard.soldout == undefined ||self.currStandard.count < self.currStandard.soldout){
                self.currStandard.count += 1;
            }else{
                alert('该菜品规格数量已经不能再多啦');
            }
        };
        self.currStandard_click = function (val) {
            $scope.currMenuItem.entity.currStandard = val;
            _.forEach(self.standards,function(item){
                item.count=0;
            });
            if(_.some($scope.cart.items,['code',self.code ])){
                _.forEach((_.filter($scope.cart.items,['code',self.code])),function(item){
                    _.forEach(_.filter(self.standards,function(val){
                        return item.standrand.price+item.standrand.unit+item.standrand.unitNo == val.price+val.unit+val.unitNo;
                    }),function(v){
                        console.log(v);
                        v.count = item.count;
                    })
                })
            };
            $scope.currMenuItem.entity.currStandard.currRecipes = [];
        };
        self.currRecipe_click = function (val) {
            if (self.currRecipes.indexOf(val) == -1) {
                self.currRecipes.push(val);
            } else {
                self.currRecipes = _.remove(self.currRecipes, function (n) {
                    return n != val;
                })
            }
        };
        self.chooses_ok_click = function () {
            if( self.hasCountMeal()){
                $scope.cart.addToCart();
                $scope.currMenuItem.entity = undefined;
                $scope.currMenuItem.isOneStandardMeal = false;
                console.log($scope.cart);
            };
             /*   _.forEach(_.filter(self.standards,function(v){return v != self.currStandard}), function (i) {
                    i.count = 1;
                })*/


        };
        self.return_click = function () {
            _.forEach(self.standards,function(item){
                item.count=0;
            });
            if(_.some($scope.cart.items,['code',self.code ])){
                _.forEach((_.filter($scope.cart.items,['code',self.code])),function(item){
                    _.forEach(_.filter(self.standards,function(val){
                        return item.standrand.price+item.standrand.unit+item.standrand.unitNo == val.price+val.unit+val.unitNo;
                    }),function(v){
                        console.log(v);
                        v.count = item.count;
                    })
                })
            };
            $scope.currMenuItem.entity = undefined;
            $scope.currMenuItem.isOneStandardMeal = false;
        }
    };

    //套餐对象
    function SetMeal(_par) {
        var self = this;
        self.name = _par.name;
        self.code = _par.code;

        // 明细
        self.picpath = _par.picpath;
        self.types = _par.setmeal.types;
        self.currMealType = self.types[0];
        self.currItem = undefined;
        self.mealList = _.map(_par.setmeal.mealList, function (val) {
            val.defaultSelected = false;
            return new SetMealItem(val);
        });

        // 规格
        self.standards = _par.standards;
        self.currStandard = self.standards[0];
        self.btnMinusCount_click = function () {
            if (self.currStandard.count > 0) {
                self.currStandard.count--;
            }
        };
        self.btnAddCount_click = function () {
            self.currStandard.count++;
        };

        self.chooseCurrMealTypes_click = function (data) {
            self.currMealType = data;
        };
        self.totalCount = function (val) {
            return _.sum(_.map(_.filter(self.mealList, {"typecode": val, defaultSelected: true}),function(item){ return item.count}));
            /*            return _.filter(self.mealList, {"typecode": val, defaultSelected: true}).length;*/
        };
        self.totalPrice = function () {
            var sum = 0;
            _.forEach(_.filter(self.mealList, ['defaultSelected', true]), function (val) {
                sum = sum + val.price * val.count;
            });
            return sum;
        };
        self.chooseMeal_ok_click = function () {
            if ($scope.currMenuItem.entity.hasCountSetMeal()) {
                $scope.cart.addToCart();
                self.currStandard.count = 0;
                $scope.currMenuItem.entity = undefined;
            }
        };
        self.return_click = function () {
            $scope.currMenuItem.entity.currStandard.count = 0;
            $scope.currMenuItem.entity = undefined;
        };
        //判断套餐的菜品项被选数量是否等于应选数量
        self.hasCountSetMeal = function () {
            return  _.sum(_.map(_.filter(self.mealList,['defaultSelected',true]),'count')) == _.sum(_.map(self.types, 'max')) && self.currStandard.count > 0;
        };
        //提示未选菜品消息
        self.btnChooseMealOK_text = function () {
            for (var i = 0; i < self.types.length; i++) {
                var type = self.types[i];
                var total = self.totalCount(type.code);
                if (type.max > total) {
                    return type.typeName + '还差' + String(type.max - total) + '个必选';
                }
            }
            return '确认';
        };

        _.forEach(self.types, function (val) {
            var filterMeals = _.filter(self.mealList, ['typecode', val.code]);
            if (val.max == _.sum(_.map(filterMeals,'count'))) {
                _.forEach(filterMeals, function (item) {
                    item.defaultSelected = true;
                })
            }
        });
    };

    //套餐item对象
    function SetMealItem(_par) {
        var self = this;
        self.name = _par.name;
        self.code = _par.code;
        self.typecode = _par.typecode;
        self.unit = _par.unit;
        self.unitNo = _par.unitNo;
        self.price = _par.price;
        self.defaultSelected = _par.defaultSelected;
        self.count = _par.count;
        self.maxCount = _par.maxCount;
        self.recipes = _par.recipes;
        self.remark = _par.remark;
        self.currRecipes = _par.currRecipes || [];
        self.chooseItem_change = function () {
            if (self.defaultSelected) {
                $scope.currMenuItem.entity.currMealRecipes = self.recipes;
                var maxCount  = _.filter($scope.currMenuItem.entity.types, ['code', self.typecode])[0].max;
                if(_.sum(_.map(_.filter(_.filter($scope.currMenuItem.entity.mealList, ['typecode', self.typecode]), ['defaultSelected', true]),'count')) == maxCount){
                    for (var i = 0; i < $scope.currMenuItem.entity.types.length; i++) {
                        var type = $scope.currMenuItem.entity.types[i];
                        var total = $scope.currMenuItem.entity.totalCount(type.code);
                        if (type.max > total) {
                            $scope.currMenuItem.entity.currMealType = type;
                            return;
                        }
                    }
                };
                if(_.sum(_.map(_.filter(_.filter($scope.currMenuItem.entity.mealList, ['typecode', self.typecode]), ['defaultSelected', true]),'count')) > maxCount){
                    alert('该类别最多选择'+ maxCount + '份,可取消选择该类型的已选菜品');
                    self.defaultSelected = false;
                };
            };
        };
        self.currRecipe_click = function (val) {
            console.log('this', this);
            if (self.currRecipes.indexOf(val) == -1) {
                self.currRecipes.push(val);
            } else {
                self.currRecipes = _.remove(self.currRecipes, function (n) {
                    return n != val;
                })
            }
        }
        //套餐菜品项是否等于当前选择套餐菜品类别的最大值
        self.isEqualMaxCount = function () {
            return _.sum(_.map(_.filter(_.filter($scope.currMenuItem.entity.mealList, ['typecode', self.typecode]), ['defaultSelected', true]),'count')) == _.filter($scope.currMenuItem.entity.types, ['code', self.typecode])[0].max;
        };

        self.btnMinusMealItemCount_click = function () {
            if (self.count > 0) {
                self.count--;
            }
        };
        self.btnAddMealItemCount_click = function () {
            console.log($scope.currMenuItem.entity.totalCount(self.typecode), self.maxCount);
            if ($scope.currMenuItem.entity.totalCount(self.typecode) == $scope.currMenuItem.entity.currMealType.max) {
                alert("最多只能选" + $scope.currMenuItem.entity.currMealType.max + "项哦");
                return;
            }
            if (self.count < self.maxCount)
                self.count++;
            else
                alert("该项最多只能选" + self.count + "项哦");
            console.log($scope.currMenuItem.entity.hasCountSetMeal());
        };
    };

    //购物车对象
    function CartItem(_par) {
        var self = this;
        self.code = _par.code;
        self.name = _par.name;
        self.standrand ={
            count: _par.currStandard.count,
            price:_par.currStandard.price,
            sprice:_par.currStandard.sprice,
            unit:_par.currStandard.unit,
            unitNo:_par.currStandard.unitNo,
            soldout:_par.currStandard.soldout
        };
        self.recipes = _par.currRecipes;
        self.price = _par.price;
        self.isOneStandards = _par.isOneStandards;
        self.remark = _par.remark;
        self.setMeal = _.filter(_par.mealList, function (i) {
            return i.defaultSelected
        });
        if( self.setMeal.length > 0 ){
              var sum = 0;
              _.forEach(self.setMeal, function (val) {
                sum = sum + val.price * val.count;
            });
              self.price = sum;
        }
        self.count = _par.currStandard.count;
        self.pkey = function () {
            return self.code + self.standrand.unitNo + _.join(_.sortBy(self.recipes)) + _.join(_.sortBy(_.map(self.setMeal, 'code')));
        };
        self.btnMinusCartCount_click = function () {
            self.count--;
            if( self.count == 0){
                $scope.cart.items = _.remove($scope.cart.items, function (data) {
                    return self.pkey() != data.pkey();
                });
                _.find($scope.menu.menuItems,['code',self.code]).standards[0].count = 0;
                if ($scope.cart.items.length == 0) {
                    $scope.cart.showMask = false;
                }
            }
            _.forEach((_.filter($scope.menu.menuItems,['code',self.code])),function(item){
                _.forEach(_.filter(item.standards,function(val){
                    return  self.standrand.price+self.standrand.unit+self.standrand.unitNo == val.price+val.unit+val.unitNo;
                }),function(v){
                    console.log(v);
                    v.count = self.count;
                })
            })

        };
        self.btnAddCartCount_click = function () {
            if(self.standrand.soldout == undefined || self.count < self.standrand.soldout){
                self.count += 1;
            }else {
                alert('该菜品规格数量已经不能再多啦')
            }
        };
    };
    // 匿名对象
    $scope.cart = {
        items: [],
        showMask: false,
        itemCount: function (_item) {
            return _.sum(_.map(_.filter($scope.cart.items, ['code', _item.code]), 'count'));
        },
        hasCart: function () {
            return $scope.cart.items.length > 0;
        },
        totalPrice: function () {
            return  _.sum(_.map($scope.cart.items, function (_item) {
                if (_item.setMeal.length == 0) {
                    return _item.standrand.price * _item.count;
                } else {
                    return (_.sum(_.map(_item.setMeal, function (_setMealItem) {
                        return _setMealItem.count * _setMealItem.price;
                    }))) * _item.count;
                }
            })).toFixed(2);
        },
        totalCount: function () {
            return _.sum(_.map($scope.cart.items, 'count'));
        },
        addToCart: function () {
            var currCartItem = new CartItem($scope.currMenuItem.entity);
            var findCartItem = _.find($scope.cart.items, function (_cart) {
                return _cart.pkey() == currCartItem.pkey();
            });
            console.log(currCartItem,findCartItem);
            if (findCartItem && currCartItem.setMeal.length == 0) {
                findCartItem.count = currCartItem.count;
            }else if (findCartItem && currCartItem.setMeal.length != 0) {
                findCartItem.count = currCartItem.count + findCartItem.count;
            } else {
                console.log(currCartItem);
                $scope.cart.items.push(currCartItem);
            }
            ;
            console.log('cart', $scope.cart.items);
        },
        minusToCart: function () {
            var currCartItem = new CartItem($scope.currMenuItem.entity);
            if (currCartItem.count != 0) {
                (_.filter($scope.cart.items, ['code', currCartItem.code]))[0].count = currCartItem.count;
            }
            else {
                $scope.cart.items = _.remove($scope.cart.items, function (val) {
                    return val.pkey() != currCartItem.pkey();
                });
                console.log($scope.cart.items, currCartItem);
            }
        },
        showCartDetail_click: function () {
            $scope.cart.showMask = true;
        },
        cancelMask_click: function () {
            $scope.cart.showMask = false;
        },
        btnCancelCart_click: function () {
            _.forEach( $scope.cart.items,function(val){
                _.forEach(_.filter($scope.menu.menuItems,['code',val.code])[0].standards,function(item){
                    item.count = 0;
                })
            });
            $scope.cart.items = [];
            $scope.cart.showMask = false;
        },
        //结算事件
        payBill_click: function () {
            var billData = {
                GUID: billid,
                BillType: $stateParams.type || 'TangShi',
                BillItems: [],
                BillItemCount: $scope.cart.totalCount(),
                OrderTotal: $scope.cart.totalPrice().toString(),
                MemberID: $scope.memberDetail.id,
                TableNo: $scope.billData.billInfo.TableNo || '',
                BillStatus: 0,
                CustomerName: $scope.billData.billInfo.CustomerName || '',
                CustomerPhone: $scope.billData.billInfo.CustomerPhone || '',
                CustomerAddress: $scope.billData.billInfo.CustomerAddress || '',
                CustomerCount: $scope.billData.billInfo.CustomerCount || 1,
                CustomerMealTime: $scope.billData.billInfo.CustomerMealTime || new Date(),
                CustomerRemark: $scope.billData.billInfo.CustomerRemark || '',
                LID: $stateParams.code,
                PrintStatue: 0
            };
            if ($stateParams.tableno)
                billData.TableNo = $stateParams.tableno;

            $scope.cart.items.forEach(function (item, index) {
                if (item.setMeal.length == 0) {
                    billData.BillItems.push({
                        ItemCode: item.code,
                        ItemName: item.name,
                        ItemCount: item.count,
                        ItemPrice: item.standrand.price,
                        ItemStandard: item.standrand.unit,
                        ItemStandardNo: item.standrand.unitNo,
                        Recipes: (item.recipes || []).join(','),
                        Remark: item.remark,
                    });
                } else {
                    item.setMeal.forEach(function (val) {
                        billData.BillItems.push({
                            ItemCode: val.code,
                            ItemName: val.name,
                            ItemCount: val.count,
                            ItemPrice: val.price,
                            ItemStandard: val.unit,
                            ItemStandardNo: val.unitNo,
                            Recipes: (val.currRecipes || []).join(','),
                            Remark: item.remark,
                            MealID: item.code,
                            MealName: item.name,
                            MealCount: item.count,
                            MealGroup: index.toString()
                        });
                    })
                }
            });
            if ((billid || '') != '') {
                //if (billid != '' && billid != undefined&& billid != null) {
               
                httpPlus
                    .MMB2RRRApi('MBBillHis/UpdateBill', {
                        _billHis: billData,
                    })
                    .then(function (_data) {
                        location.href = '../../QuickPay/PayBill2.aspx?billid=' + _data.BillGUID + "&tableno=" + _data.TableNo
                    })
                    .catch(function(err){
                        alert(err.ResultMsg);
                        maskPlus.hideLoading();
                    })
            } else {
                httpPlus
                .MMB2RRRApi('MBBillHis/CreateBill', {
                    _billHis: billData
                    })
                    .then(function (_data) {
                        location.href = '../../QuickPay/PayBill2.aspx?billid=' + _data.BillGUID + "&tableno=" + _data.TableNo
                    })
                    .catch(function(err){
                        alert(err.ResultMsg);
                        maskPlus.hideLoading();
                    })
            }

        },
    };
    $scope.menu = {
        menuTypes: {},
        menuItems: [],
       /* isShowbigModel:true,
        isFloatButton:true,*/
        chooseSmallPhoto_click:function(){
            $scope.menu.isShowbigModel = !$scope.menu.isShowbigModel;
            if(!$scope.menu.isShowbigModel){
                $scope.currMenuType.menuType = $scope.menu.menuTypes[0];
            }else {
                $scope.currMenuType.menuType = undefined;
            }
        },
        // ng-click='menu.btnChooseItem_click(item)'
        btnChooseItem_click: function (_menuItem,data) {
            console.log(data);
            $scope.currMenuItem.addToCreateByMenuItem(_menuItem,data);
            console.log($scope.currMenuItem.entity);
        },
        btnMinusCount_click: function (_menuItem) {
            $scope.currMenuItem.minusToCreateByMenuItem(_menuItem);
        },
        btnChooseCurrType_click: function (_menuType) {
            $scope.currMenuType.menuType = _menuType;
        }
    };
    $scope.billData = {
        billInfo: {},
        billItemsInfo: []
    };
    $scope.currMenuType = {
        menuType: undefined,
    }
    $scope.currMenuItem = {
        entity: undefined,
        isMeal: function () {
            return $scope.currMenuItem.entity instanceof NormalMenuItem && !$scope.currMenuItem.entity.isOneStandards();
        },
        isSetMeal: function () {
            return $scope.currMenuItem.entity instanceof SetMeal;
        },
        isOneStandardMeal:false,
        addToCreateByMenuItem: function (_menuItem,data) {
            console.log(_menuItem);
            if (_menuItem.setmeal.types.length == 0) {
                // normal
                $scope.currMenuItem.entity = new NormalMenuItem(_menuItem);
                console.log($scope.currMenuItem.entity);
                if ($scope.currMenuItem.entity.isOneStandards()) {
                    if(data != undefined){
                        $scope.currMenuItem.isOneStandardMeal = true;
                        console.log( $scope.currMenuItem.isOneStandardMeal);
                    }else {
                        $scope.currMenuItem.isOneStandardMeal = false;
                        if($scope.currMenuItem.entity.currStandard.soldout == undefined || ($scope.currMenuItem.entity.currStandard.count)< $scope.currMenuItem.entity.currStandard.soldout){
                            $scope.currMenuItem.entity.currStandard.count += 1;
                        }else {
                            return alert('该菜品数量已经不能再多啦')
                        }
                        $scope.cart.addToCart();
                    }

                } else {
                   /* console.log($scope.cart.items);
                    if(!_.some($scope.cart.items,['code',_menuItem.code])){
                           _.forEach($scope.currMenuItem.entity.standards,function(val){
                              val.count = 1;
                            })
                    }*/

                }
            } else {
                // meal
                $scope.currMenuItem.entity = new SetMeal(_menuItem);
                console.log($scope.currMenuItem.entity);
                $scope.currMenuItem.entity.currStandard.count += 1;
            }
        },
        minusToCreateByMenuItem: function (_menuItem) {
            console.log(_menuItem);
            if (_menuItem.setmeal.types.length == 0 && _menuItem.standards.length == 1 && _menuItem.recipes.length == 0) {
                $scope.currMenuItem.entity = new NormalMenuItem(_menuItem);
                $scope.currMenuItem.entity.currStandard.count -= 1;
                $scope.cart.minusToCart();
            } else {
                alert("只允许在购物车内删除哦");
            }
        },
        createByCartItem: function (_cartItem) {
            $scope.setMeal.entity = {
                mode: 'edit'
            };
        }
    };
    //初始化数据
    httpPlus
        .MMB2RRRApi('MenuBoard/InitBillDetail', {
            _billGUID: billid || '',
            _shopCode: $stateParams.code,
            _datamd5: ''
        })
        .then(function (data) {
            if (!data.wechatOrderNewVersion180125) {
                var oldVersionUrl = '../../DianCai2/BillDetail3.aspx?';
                var oldVersionUrlParams = [];
                if ($stateParams.type) oldVersionUrlParams.push('type=' + $stateParams.type);
                if ($stateParams.mode) oldVersionUrlParams.push('mode=' + $stateParams.mode);
                if ($stateParams.billid) oldVersionUrlParams.push('billid=' + $stateParams.billid);
                if ($stateParams.code) oldVersionUrlParams.push('code=' + $stateParams.code);
                if ($stateParams.tableno) oldVersionUrlParams.push('tableno=' + $stateParams.tableno);
                oldVersionUrl += oldVersionUrlParams.join('&');
                return window.location.href = oldVersionUrl;
            }
            _.forEach(data.menuitem, function (val) {
                val.setmeal = {types: [], mealList: []};
                if (!val.isSetMeal) return;

                val.setMealItems.forEach(function (item) {
                    val.setmeal.types.push({
                        typeName: item.groupName,
                        code: item.groupID,
                        max: item.groupMaxCount
                    });
                    item.groupItems.forEach(function (item1) {
                        val.setmeal.mealList.push({
                            code: item1.code,
                            name: item1.name,
                            typecode: item.groupID,
                            count: item1.count,
                            price: item1.price,
                            defaultSelected: item1.defaultSelected,
                            unit: item1.unit,
                            unitNo: item1.unitNo,
                            recipes: item1.recipes,
                        });
                    });
                });
            });
            _.forEach(data.menuitem, function (val) {
                _.forEach(val.standards, function (i) {
                    i.count = 0;
                });
               if( !_.some(val.standards,function(i){
                    return i.soldout == undefined || i.soldout != 0;
                })){
                   val.isSoldOut = true;
               }else {
                   val.isSoldOut = false;
               }
            });
            $scope.menu.menuTypes = data.menutype;
            $scope.menu.menuItems = data.menuitem;
            $scope.memberDetail = data.memberinfo;
         /*   $scope.menu.isShowbigModel = data.WechatPhotoLargeSize;
            $scope.menu.isFloatButton = data.WechatFloatButtonFlat;*/
            $scope.menu.commendItems = _.filter(data.menuitem,['isRecommend',1]);
            if (data.billInfo) {
                $scope.billData.billInfo = data.billInfo;
                $scope.billData.billItemsInfo = data.billItemsInfo;
                if (_.filter(data.billItemsInfo, function (val) { return val.MealID }).length > 0) {
                    var meal = _.groupBy(_.filter(data.billItemsInfo, function (val) {return val.MealID}), 'MealGroup');
                    var mealList = [];
                    for (var i in meal) {
                        mealList.push(meal[i]);
                    };
                    console.log(mealList);
                    $scope.cart.items = _.concat(_.map(mealList, function (val) {
                        return new CartItem({
                            code: val[0].MealID,
                            name: val[0].MealName,
                            currStandard: {
                               // price: _.sum(_.map(val,function(v){return v.})),
                                unit: val[0].ItemStandard,
                                unitNo: val[0].ItemStandardNo,
                                count: val[0].MealCount
                            },
                            currRecipes: [],
                            remark: val[0].Remark,
                            mealList: _.map(val, function (v) {
                                return new SetMealItem({
                                    name: v.ItemName,
                                    code: v.ItemCode,
                                    defaultSelected: true,
                                    count: v.ItemCount,
                                    price: v.ItemPrice,
                                    unit: v.ItemStandard,
                                    unitNo: v.ItemStandardNo,
                                    currRecipes: (v.Recipes || '').split(','),
                                })
                            })
                        })
                    }), $scope.cart.items);
                };
                console.log($scope.cart);
                if (_.filter(data.billItemsInfo, function (val) {
                        return val.MealID == null
                    }).length > 0) {
                    var aa = _.filter(data.billItemsInfo, function (val) {
                        return val.MealID == null
                    });
                    $scope.cart.items = _.concat(_.map(aa, function (i) {
                        return new CartItem({
                            code: i.ItemCode,
                            name: i.ItemName,
                            currRecipes: (i.Recipes || '').split(','),
                            currStandard: {
                                price: i.ItemPrice,
                                unit: i.ItemStandard,
                                unitNo: i.ItemStandardNo,
                                count: i.ItemCount
                            },
                            remark: i.Remark,
                            setMeal: [],
                        })
                    }), $scope.cart.items);
                    //将购物车项的数量同步到给菜单菜品里的数量
                    _.forEach($scope.menu.menuItems,function(item){
                        _.forEach($scope.cart.items,function(i){
                            if(item.code == i.code){
                               _.filter(item.standards,function(v){return v.unitNo == i.standrand.unitNo})[0].count = i.standrand.count;
                            };
                        })
                    });
                    console.log($scope.menu.menuItems);
                }

            }
            if ($scope.menu.menuTypes && ! $scope.menu.isShowbigModel) {
                $scope.currMenuType.menuType = $scope.menu.menuTypes[0];
            }
            ;
            console.log(document.documentElement.style.fontSize);
        })
        .catch(function(err){
            alert(err.ResultMsg);
        })
}]);